﻿
using System.Windows.Controls;
using System.Windows.Navigation;
using LogViewApp.Resources;
using System.IO;
using LogViewApp.ViewModel;
using System.Windows;
using System.Collections.Generic;
using LogViewApp.Models;

namespace LogViewApp
{
    public partial class Home : Page
    {


        public Home()
        {
            InitializeComponent();
            HomeViewModel homeViewModel = this.DataContext as HomeViewModel;
            homeViewModel.owner = this;
            this.Title = ApplicationStrings.HomePageTitle;
        }



        /// <summary>
        ///     Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void Border_Drop(object sender, System.Windows.DragEventArgs e)
        {
            FileInfo[] fileInfos = e.Data.GetData("FileDrop") as FileInfo[];
            HomeViewModel homeViewModel = this.DataContext as HomeViewModel;
            if (homeViewModel != null)
            {
                homeViewModel.HandleFileDrop(fileInfos);
            }
        }

        private void Grid_DragEnter(object sender, System.Windows.DragEventArgs e)
        {
            HomeViewModel homeViewModel = this.DataContext as HomeViewModel;
            if (homeViewModel != null)
            {
                homeViewModel.HandleFileDropEnter();
            }
        }

        private void Grid_DragLeave(object sender, System.Windows.DragEventArgs e)
        {
            HomeViewModel homeViewModel = this.DataContext as HomeViewModel;
            if (homeViewModel != null)
            {
                homeViewModel.HandleFileDropLeave();
            }
        }
    }
}